package cn.itcast.bos.service.filter;

import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
//由于Struts的拦截器会拦截掉webService的请求,使用配置此类,过滤webService的请求
public class MyStrutsFilter extends StrutsPrepareAndExecuteFilter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        if(req.getServletPath().contains("/service")){
            chain.doFilter(request,response);
        }else{
            super.doFilter(request,response,chain);
        }
    }
}
